<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script type="text/javascript"	src="./js/dtree.js"></script>
<link rel="StyleSheet" href="./css/dtree.css" type="text/css" />
<html>
<body  bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0">
<input type="hidden" name="steptype" value="4"/>
<div class="dtree" style="width:700px;height:400px;overflow: auto;" >
	<script type="text/javascript">
		var d = new dTree('d');
		d.check = false; 
		d.add('0','-1','产品/服务分类');
	
		<c:forEach var="supagent" items="${prodCateList}">
			<c:if test="${supagent.pk_da_prod_cate_pre==null}">
				d.add('${supagent.pk_da_prod_cate}','0','${supagent.cate_name}','${supagent.pk_da_prod_cate}'); 
			</c:if>
			<c:if test="${supagent.pk_da_prod_cate_pre!=null}">
				d.add('${supagent.pk_da_prod_cate}','${supagent.pk_da_prod_cate_pre}','${supagent.cate_name}','${supagent.pk_da_prod_cate}');
			</c:if>
		</c:forEach>

		document.write(d);

		function xxx(ooo){
			alert(1);
			if(ooo != null){
				alert(ooo.id);
			}
		}
	</script>
</div>
<div align="center">
	<input type="button" onclick="calbackoper()" value="确定"/>
</div>
</body>
<script type="text/javascript">
	var calBackValues = "";
	var calBackPks = "";
	var calVals = "";
	window.onload = function()
	{
		//获取父窗体已选中的分类的内容
		var conent = window.dialogArguments.document.getElementsByName('tgcplb')[0].value;
		var p_pk = window.dialogArguments.document.getElementsByName('zdy8')[0].value;
		var conents = conent.split(",");
		var p_pks = p_pk.split(",");
		if((conent != null) && (conent != "")){
			for(var index = 0; index < conents.length; index++){
				document.getElementById(p_pks[index]+'-'+conents[index]).checked = true;
			}
		}
	}
	window.onbeforeunload = function()  
	{  
		if(calBackValues==""){
			window.returnValue="";
		}else{
			window.returnValue=calBackValues.substring(0,calBackValues.length-1)+";"+calBackPks.substring(0,calBackPks.length-1);
		}
	}

	function calbackoper(){
		//获取所有的叶子节点
		var pk_da_prod_cate = document.getElementsByName("haha");
		calBackValues = "";
		calBackPks = "";
		for(var i=0;i<pk_da_prod_cate.length;i++){
			//获取选中的叶子节点
			if(pk_da_prod_cate[i].checked==true){
				calVals += pk_da_prod_cate[i].id+";";
			}
		}
		calVals = calVals.substring(0,calVals.length-1);
		//取出每个选中的叶子节点的pk-name
		var pknames = calVals.split(";");
		for(var j=0;j<pknames.length;j++){
			var pk_names = pknames[j].split("-");
			//获取选中的节点的pk，进行拼接
			calBackPks += pk_names[0] + ",";
			//获取选中的节点的name，进行拼接
			calBackValues += pk_names[1] + ",";
			}
		if(calBackValues==""){
			window.returnValue="";
		}else{
			window.returnValue=calBackValues.substring(0,calBackValues.length-1)+";"+calBackPks.substring(0,calBackPks.length-1);
		}
		//window.onbeforeunload();
		window.close();
	}
</script>
</html>
